<?php

require '../model/gongaomodel.php';

class gongaocontrol{
	private $model;//业务模型
	private $view;

	public function __construct(){
		
		$this->view="../view/main.php?url=gongao.php";
		$this->model=new gongaomodel();
	}


	public function load($view=null){
		if(empty($view))
		{				
			header("location:{$this->view}");
		}
		else{
			header("location:{$view}");
		}

	}
	
	/*
	 *
	*
	*/
	public function doAction($action){


		if($action=='gongaoquery'){
			
			$this->action_gongaoquery();
		}
		else if ($action=='gongaotian'){
			
			$this->action_gongaotian();
		}
		else{
			$this->load();
		}

	}

	//公告查询
	public function action_gongaoquery(){
			
		//回自己界面
		$this->load($this->view."&gongaoid=".$_POST['gongaoid']);
		
	}
	//公告添加
	public function action_gongaotian(){
		if (!empty($_POST['gongao'])){
			$upload=new upload();
			$img=$upload->upload_file();
	    $gongao=new  gongaomodel();
	    $gongao->gongaotian($_POST['gongao'],$img);
		}
		
		else {
			
		}
		//回自己界面
		$this->load($this->view);
	}
	
}
?>